package group.sicher.core.web.context;

import group.sicher.core.cache.CacheService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SicherContextProviderImp implements SicherContextProvider {


    @Autowired
    private CacheService cacheService;

    @Override
    public HxContextEntry getHxContextEntry() {
        return new HxContextEntry();
    }

    @Override
    public HxContextEntry getHxContextEntry(String token) throws Exception {
        Integer temp = (Integer) cacheService.get(token);
        Long userId = Long.valueOf(temp);
        HxContextEntry contextEntry = new HxContextEntry();
        contextEntry.setToken(token);
        contextEntry.setUserId(userId);
        return contextEntry;
    }
}
